package com.fesine.ext.service.impl;

import com.fesine.ext.dao.StudentMapper;
import com.fesine.ext.model.Student;
import com.fesine.ext.service.StudentServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/10/11 10:53
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/10/11 10:53
 */
@Service("studentService")
public class StudentServiceImpl implements StudentServiceI {

    private StudentMapper studentMapper;

    @Autowired
    public void setStudentMapper(StudentMapper studentMapper) {
        this.studentMapper = studentMapper;
    }

    //注解使用缓存-key=getStudent
    @Cacheable("getStudent")
    @Override
    public Student getStudent(Integer sid) {
        return studentMapper.selectByPrimaryKey(sid);
    }

    //清除缓存
    @CacheEvict(value = {"getStudent"},allEntries = true)
    @Override
    public int updateStudent(Student student) {
        return studentMapper.updateByPrimaryKey(student);
    }
}
